<?php 

Class indexModel extends appModel
{

	public function getFavor()
	{
		$sql="SELECT * FROM ".$this->table('favor')."";
		return $this->getAll($sql);
	}
	public function check_user($username,$password)
	{
		 $sql = "SELECT u.id,u.password,u.username,ar.role_action FROM " . $this->table('admin').
                   " as u," . $this->table('admin_role').
                   " as ar WHERE u.group_id=ar.id AND u.username = '" . $username .  "' AND u.password = '" . md5($password). "'";
		 $row = $this->getRow($sql);
            
            	
            	if ($row&&$username==$row['username']&&md5($password)==$row['password'])
               {
               	session('admin_id',$row['id']);
               	session('admin_name',$row['username']);
               	session('admin_action',$row['role_action']);
               	cookie('QIAQIA[admin_id]',   $row['id'],array('expire'=>3600*24));
               	
               	cookie('QIAQIA[admin_pass]', md5($row['password']),array('expire'=>3600*24));
               	return true;
               }
               else
               {
               	return false;
               }
            	
            
		
		
		
	}
}